import numpy as np

# 创建一个范围内的数组并计算其平方和
squares = np.array([x**2 for x in range(10)])
sum_of_squares = squares.sum()
print(f"Sum of squares from 0 to 9 using NumPy: {sum_of_squares}")

# 使用切片操作创建一个新的子数组，但不影响原始数组
nums = np.array([1, 3, 5, 7, 8, 13, 20])
sub_array = nums[:4]  # 选取前四个元素
print(f"Sub-array: {sub_array}")
print(f"Original array unchanged: {nums}")